<template>
  <div class="container">
    <div v-if="tableData == ''">暂无审核订单，您今日的审核订单已全部完成！</div>
    <div v-else>
      <div
        style="background-color: #fff;margin-bottom: 1px;border-radius: 4px 0px;padding:10px;height: 100px;line-height: 30px;">
        <el-row :gutter="20">
          <el-col :span="6">
            <div>订单号：{{ tableData.trade_no }}</div>
          </el-col>
          <el-col :span="6">
            <div>下单时间：{{ tableData.create_time }}</div>
          </el-col>
          <el-col :span="6">
            <div>来源：{{ tableData.source }}</div>
          </el-col>
          <el-col :span="6">
            订单号：<el-input v-model="searchId.orderId" style="width: 210px;" clearable/><el-button style="margin-left: 5px;" @click="handleSet">设置</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="12">
            <div>定位城市：{{ tableData.location }}</div>
          </el-col>
          <el-col :span="6">
            <div>下单设备型号：{{ tableData.device }}</div>
          </el-col>
        </el-row>
      </div>
      <div class="border_cls" style="border-top-right-radius: 0px;border-top-left-radius: 0px;">
        <el-row>
          <el-col>
            <div class="font_cls">订单信息</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">合同类型</el-col>
          <el-col :span="6">免押类型</el-col>
          <el-col :span="6">免押金额</el-col>
          <el-col :span="6">已交押金</el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="6">
            <div class="bor_cls">{{ tableData.pay_type == 1 ? "智能合同代扣" :
              tableData.pay_type == 2 ? "支付宝预授权（" + (tableData.rights_auth_no != 0 ? "已授权代扣" : "未授权代扣") + "）" :
                tableData.pay_type == 7 ? "银行卡代扣" :
                  "花呗" }}</div>
          </el-col>
          <el-col :span="6">
            <div class="bor_cls">
            {{ tableData.foregift_deduct == 0 ? "未授权免押" : tableData.foregift_pay > 0 ? "部分免押" : "押金全免" }}  
            </div>
          </el-col>
          <el-col :span="6">
            <div class="bor_cls">￥{{ tableData.foregift_deduct == null ? '0.00' : tableData.foregift_deduct }}</div>
          </el-col>
          <el-col :span="6">
            <div class="bor_cls">￥{{ tableData.foregift_pay == null ? '0.00' : tableData.foregift_pay }}</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="18">
            风控信息： {{ tableData.is_skip == 1 ? '【未风控】商家跳过风控' : tableData.risk }}
            <el-button v-if="tableData.is_skip == 0 && $hasMethod('#riskControl') && tableData.risk == ''" size="mini"
              class="border-btn" @click="openTip(tableData)">蚁盾风控</el-button>
            <!-- <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="selectRisk(item)">查看大数据
                  </el-button> -->
            <!-- <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="antsDialog(tableData)"> 蚂蚁风控
            </el-button> -->
            <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="handleOrderData(tableData)">查看大数据
            </el-button>
            <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="radarDialog(tableData)">查看雷达风控数据
            </el-button>
            <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="billAbDialog(tableData)">查看钞能力数据
            </el-button>
            <el-button size="mini" class="border-btn" style="padding: 0 1px;" @click="selectCredit(tableData)">{{
              isSuccess == 1 ? '已查询征信风控报告' : isSuccess == 2 ? '该用户征信查询失败' : isSuccess == 3 ? '查询征信申请中' : '查看征信风控报告'
            }}</el-button>
          </el-col>
          <el-col :span="6" style="margin-top: 10px;">
            签署协议：
            <el-tooltip class="item" effect="dark" content="用户授权协议已签署" placement="top-start">
              <img v-if="tableData.flow_id_2" src="../../assets/images/db-signed.png" alt="用户授权协议已签署" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="用户授权协议未签署" placement="top-start">
              <img v-if="!tableData.flow_id_2" src="../../assets/images/db-unsign.png" alt="用户授权协议未签署" />
            </el-tooltip>

            <el-tooltip class="item" effect="dark" content="个人征信授权书已签署" placement="top-start">
              <img v-if="tableData.flow_id_3" src="../../assets/images/db-signed.png" alt="个人征信授权书已签署" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="个人征信授权书未签署" placement="top-start">
              <img v-if="!tableData.flow_id_3" src="../../assets/images/db-unsign.png" alt="个人征信授权书未签署" />
            </el-tooltip>

            <el-tooltip class="item" effect="dark" content="融资租赁委托担保合同已签署" placement="top-start">
              <img v-if="tableData.flow_id_4" src="../../assets/images/dan_yes.png" style="width: 21px;height: 23px;"
                alt="融资租赁委托担保合同已签署" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="融资租赁委托担保合同未签署" placement="top-start">
              <img v-if="!tableData.flow_id_4" src="../../assets/images/dan_no.png" style="width: 21px;height: 23px;"
                alt="融资租赁委托担保合同未签署" />
            </el-tooltip>

            <el-tooltip class="item" effect="dark" content="租赁合同未签署" placement="top-start">
              <img v-if="tableData.sign_status != 1 && tableData.sign_status != 2" src="../../assets/images/unsign.png"
                alt="合同未签署" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="租赁合同签署中" placement="top-start">
              <img v-if="tableData.sign_status == 1" src="../../assets/images/signing.png" alt="合同签署中" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="租赁合同已签署" placement="top-start">
              <img v-if="tableData.sign_status == 2" src="../../assets/images/signed.png" alt="合同已签署" />
            </el-tooltip>
            <el-tooltip class="item" effect="dark" content="续租订单" placement="top-start">
              <img v-if="tableData.is_renewal == 1" src="../../assets/images/renew.png" alt="续租订单" />
            </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证合同未签署" placement="top-start">
                  <img v-if="tableData.is_lease == 1" src="../../assets/images/unnotarization.png" style="width: 25px;height: 25px;" alt="公证未签署">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证合同签署中" placement="top-start">
                  <img v-if="tableData.is_lease == 2" src="../../assets/images/notarization.png"  style="width: 25px;height: 25px;" alt="公证未签署">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证合同已签署" placement="top-start">
                  <img v-if="tableData.is_lease == 3" src="../../assets/images/notarizationed.png" alt="合同已签署" @click="textContact(tableData.notar_list.contact_text)">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证申请表" placement="top-start">
                  <img v-if="!tableData.notar_list.apply_text" src="../../assets/images/unapply.png"  style="width: 25px;height: 25px;" alt="公证申请表">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证申请表已签署" placement="top-start">
                  <img v-if="tableData.notar_list.apply_text" src="../../assets/images/applyed.png" alt="公证申请表已签署" @click="textApply(tableData.notar_list.apply_text)">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证告知书" placement="top-start">
                  <img v-if="!tableData.notar_list.tell_text" src="../../assets/images/tell.png"  style="width: 25px;height: 25px;" alt="公证告知书">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="公证告知书已签署" placement="top-start">
                  <img v-if="tableData.notar_list.tell_text" src="../../assets/images/telled.png" alt="公证告知书已签署" @click="textTell(tableData.notar_list.tell_text)">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="谈话记录书" placement="top-start">
                  <img v-if="!tableData.notar_list.talk_text" src="../../assets/images/talk.png"  style="width: 25px;height: 25px;" alt="谈话记录书">
                </el-tooltip>
                <el-tooltip class="item" effect="dark" content="谈话记录书已签署" placement="top-start">
                  <img v-if="tableData.notar_list.talk_text" src="../../assets/images/talked.png" alt="谈话记录书已签署" @click="textTalk(tableData.notar_list.talk_text)">
                </el-tooltip>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="24">
            风控建议： {{ tableData.orderRemark1.remark ?tableData.orderRemark1.remark:'暂无风控建议'}}
          </el-col>
        </el-row>
      </div>
      <div class="border_cls">
        <div style="display: flex;">
          <div style="width:20% ;">
            <div class="font_cls">商品信息</div>
            <img style="height:200px;width:200px" :src="$globalObj.imgBaseUrl + tableData.imgurl" class="w-100 h-100">
          </div>
          <div style="width: 80%;">
            <el-row :gutter="20">
              <el-col :span="8">
                <div style="font-size: 16px;">商品ID: {{ tableData.goods_id }}</div>
              </el-col>
              <el-col :span="8">
                <div style="font-size: 16px;">活动商品: {{ tableData.activity_title?tableData.activity_title:'暂无活动' }}</div>
              </el-col>
              <el-col :span="8">
                <div>商品数量：{{ tableData.amount }}</div>
              </el-col>
              <!-- <el-col :span="8">
                <div>设备编号: <el-button size="medium" class="border-btn" style="margin-left:5px"
                    @click="editDevice(tableData)">更改设备编号</el-button></div>
              </el-col> -->
            </el-row>
            <el-row :gutter="20">
              <el-col :span="8">
                <div>租赁方式：{{ tableData.pact_type }}</div>
              </el-col>
              <el-col :span="8">
                <div>商品名称:({{ tableData.new_grade_title }}){{ tableData.goods_title }}</div>
              </el-col>
              <el-col :span="8">
                <div>套餐方式：{{ tableData.setmeal_title }}</div>
              </el-col>
            </el-row>
            <el-row :gutter="20">
              <el-col :span="1.5"><el-button v-if="tableData.status == 10" size="mini" type="warning"
                  @click="openDelivery(tableData.id)">订单发货</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 10" size="mini" type="danger"
                  @click="refuseorder(tableData.id)">拒绝订单</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 3" size="mini" type="success"
                  @click="checkPass(tableData.id,tableData.seller_id)"> {{ tableData.seller_id==1649320702?'转内部':'审核通过'  }}</el-button></el-col>
                  <el-col :span="1.5"><el-button v-if="tableData.status == 3&&tableData.seller_id==1649320702" size="mini" type="danger"
                  @click="refuseOrder2(tableData.id)">审核拒绝</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 3&&tableData.seller_id!=1649320702" size="mini" type="danger"
                  @click="returnOrder(tableData.id)">转回平台</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 20" size="mini" type="warning"
                  @click="confirmReceipt(tableData.id)">确认收货</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 44" size="mini" type="warning"
                  @click="confirmReturn(tableData.id)">确认归还</el-button></el-col>
              <el-col :span="1.5"><el-button
                  v-if="[20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58].indexOf(tableData.status) > -1"
                  size="mini" type="primary" @click="checkLogistics(tableData)">查看物流</el-button></el-col>
              <el-col :span="1.5"><el-button
                  v-if="[3, 9, 10, 11, 12, 13, 14, 15, 16, 20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58, 60, 61, 62, 63, 64, 65].indexOf(tableData.status) > -1 && tableData.pact_url != 0 && tableData.sign_status == 2"
                  size="mini" type="primary"
                  @click="checkPact($globalObj.imgBaseUrl + tableData.pact_url)">查看合同</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="[11, 12, 13, 14].indexOf(tableData.status) > -1" size="mini"
                  type="warning" @click="handleRefundOrder(tableData.trade_no)">去处理</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="[11, 12, 13, 14].indexOf(tableData.status) > -1" size="mini"
                  type="warning" @click="handleRefundOrder(tableData.trade_no)">去处理</el-button></el-col>
              <el-col :span="1.5"><el-button
                  v-if="[9, 10, 11, 12, 13, 14, 20, 30, 31, 32, 33, 34, 39, 40, 41, 42, 43, 44, 45, 49, 50, 51, 52, 56, 57, 58].indexOf(tableData.status) > -1"
                  size="mini" type="success" @click="finishOrder(tableData.id)">交易完成</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 41" size="mini" type="warning"
                  @click="agreeReturn(tableData.id)">同意归还</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 41" size="mini" type="danger"
                  @click="refuseReturn(tableData.id)">拒绝归还</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="[3, 9, 10, 20, 30].indexOf(tableData.status) > -1 && tableData.pact_url_4
                " size="mini" type="success">已上征信</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="[3].indexOf(tableData.status) > -1 && !tableData.pact_url_4
                " size="mini" type="primary" @click="createCreditCompany(tableData.id)">上征信</el-button></el-col>
                <el-col :span="1.5"><el-button v-if="[3].indexOf(tableData.status) > -1&&tableData.is_lease==1" size="mini" type="primary" @click="notarization(tableData.id)">上公证</el-button></el-col>
              <el-col :span="1.5"><el-button v-if="tableData.status == 3" size="mini" type="warning"
                  @click="handleOrder(tableData.id)">待处理</el-button></el-col>
                  <el-col :span="1.5"><el-button size="mini" @click="addRemark(tableData.id,9)" type="primary">添加备注</el-button></el-col>
                  <!-- <el-col :span="1.5"><el-button size="mini" v-if="tableData.seller_id==1653450768" @click="addRemark(tableData.id,1)" type="success">风控建议</el-button></el-col> -->
                  <el-col :span="1.5"><el-button v-if="tableData.status == 3" size="mini" @click="editorder(tableData, 2)" type="warning">修改租期租金</el-button></el-col>
                  
                  
            </el-row>
          </div>
        </div>
      </div>
      <div class="border_cls">
        <el-row>
          <el-col :span="1">
            <div class="font_cls">用户信息</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="4">
            <div>姓名</div>
          </el-col>
          <el-col :span="4">
            <div>性别</div>
          </el-col>
          <el-col :span="4">
            <div>年龄</div>
          </el-col>
          <el-col :span="4">
            <div>手机</div>
          </el-col>
          <el-col :span="4">
            <div>身份证号码</div>
          </el-col>
          <el-col :span="4">
            <div>地址</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.authentic.cert_name }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.authentic.sex }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.authentic.age }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.mobile }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.authentic.cert_no }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls">{{ tableData.prov + tableData.city + tableData.area + tableData.address }}</div>
            <el-button style="margin-top:10px" size="medium" class="border-btn"
              @click="editAddress(tableData)">修改地址</el-button>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="4">
            <div>身份证正面</div>
          </el-col>
          <el-col :span="4">
            <div>身份证反面</div>
          </el-col>
          <el-col :span="4">
            <div>人脸识别照片</div>
          </el-col>
          <el-col :span="4">
            <div>定位城市</div>
          </el-col>
          <el-col :span="4">
            <div>下单设备型号</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="4">
            <div><el-image style="width:200px;height:200px"
                :src="$globalObj.imgBaseUrl + tableData.authentic.idcard_front"
                :preview-src-list="[$globalObj.imgBaseUrl + tableData.authentic.idcard_front]">
              </el-image></div>
          </el-col>
          <el-col :span="4">
            <div><el-image style="width:200px;height:200px" :src="$globalObj.imgBaseUrl + tableData.authentic.idcard_back"
                :preview-src-list="[$globalObj.imgBaseUrl + tableData.authentic.idcard_back]">
              </el-image></div>
          </el-col>
          <el-col :span="4">
            <div><img style="height:200px;width:200px" :src="tableData.face_photo" class="w-100 h-100"></div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls" style="height: 30px;">{{ tableData.location == null ? "暂无地址信息" : tableData.location }}</div>
          </el-col>
          <el-col :span="4">
            <div class="bor_cls" style="height: 30px;">{{ tableData.device == null ? "暂无设备信息" : tableData.device }}</div>
          </el-col>
        </el-row>
      </div>
      <div class="border_cls">
        <el-row>
          <el-col :span="1">
            <div class="font_cls">租期信息</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="23">
            <div class="flex justify-between" style="gap: 80px;margin-bottom: 10px;">
              <div style="margin-bottom: 20px;">租赁时间: {{ tableData.begin_time }} 至 {{ tableData.end_time }}(共{{
                tableData.month_total }}期)</div>
              <div>总租金：￥{{ tableData.rent_total }}</div>
              <div>买断金：￥{{ tableData.setmeal_price }}</div>
              <div>下期付款金额：￥{{ tableData.lease.next.amount }}</div>
              <div>下期付款时间： {{ tableData.lease.next.date }}</div>
            </div>
            <div>
              <el-table :data="tableData.lease_list" style="width: 100%;text-align: center;border-radius: 8px;" border>
                <el-table-column align="center" label="期数" width="80">
                  <template slot-scope="scope">
                    <span>{{ scope.row.which_period }}/{{ tableData.month_total }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="租期">
                  <template slot-scope="scope">
                    <span>{{ scope.row.begin_time }} 至 {{ scope.row.end_time }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="租金">
                  <template slot-scope="scope">
                    <span>￥{{ scope.row.rent }}</span>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="状态" width="100">
                  <template slot-scope="scope">
                    <el-tag :type="scope.row.status == 0 || scope.row.status == 4 ? '' : 'success'">{{ scope.row.status ==
                      1
                      ? '已支付' : scope.row.status == 2 ? '已退款' : scope.row.status == 3 ? '已买断' : scope.row.status == 4 ?
                        '已逾期' : scope.row.status == 5 ? '线下支付' : '未支付' }}</el-tag>
                  </template>
                </el-table-column>
                <el-table-column align="center" label="预计扣款日" prop="begin_time"></el-table-column>
              </el-table>
            </div>
          </el-col>
        </el-row>
      </div>
      <div class="border_cls">
        <el-row>
          <el-col :span="1">
            <div class="font_cls">订单备注</div>
          </el-col>
        </el-row>
        <el-row :gutter="20">
          <el-col :span="23">
            <el-table :data="remarkList" style="width: 100%;text-align: center;border-radius: 8px;" border>
              <el-table-column prop="username" label="操作人员" align="center" />
              <el-table-column prop="remark" label="备注信息" align="center" />
              <el-table-column prop="create_time" label="时间" align="center" />
            </el-table>
          </el-col>
        </el-row>
      </div>
      <check-lease ref="checkLease" :order-id="selectedId"></check-lease>
      <set-address ref="setAddress" :edit-item="editItem" @getList="getList"></set-address>
      <set-device ref="setDevice" :edit-item="editItem" @getList="getList"></set-device>
      <set-remark ref="setRemark" :order-id="selectedId" @getList="getList" :dialog-title="titleDialog">
      </set-remark>
      <check-remark ref="checkRemark" :order-id="selectedId"></check-remark>
      <check-flow ref="checkFlow" :order-no="selectedId"></check-flow>
      <delivery ref="delivery" :order-id="selectedId" @getList="getList"></delivery>
      <receipt ref="receipt" :order-id="selectedId" @getList="getList"></receipt>
      <auth-info ref="authInfo" :edit-item="editItem"></auth-info>
      <check-bill ref="checkBill" :order-id="selectedId"></check-bill>
      <edit-order ref="editOrder" :edit-item="editItem" @getList="getList"></edit-order>
      <select-risk ref="selectRisk" :edit-item="editItem" @getList="getList"></select-risk>
      <select-credit ref="selectCredit" :edit-item="editItem" @getList="getList"></select-credit>
      <!-- 新版征信 -->
      <new-select-risk ref="newSelectRisk" :order-id="newOrderId" @setIsSuccess="setIsSuccess"></new-select-risk>
      <check-logistics ref="checkLogistics" :edit-item="editItem"></check-logistics>
      <insurance ref="insurance" :order-id="selectedId" :insurance-list="InsuranceList"></insurance>
      <param-dialog :dialogVisible="dialogVisible" :dialogType="dialogType" :responseInfo="responseInfo"
        :requestInfo="requestInfo" @close="closeDialog"></param-dialog>
      <radar ref="radarDialog" :edit-item="editItem" @getList="getList" @resp-code="respCode"></radar>
      <bill-ab-dialog ref="billAbDialog" :edit-item="editItem" @getList="getList"></bill-ab-dialog>
      <edu-details ref="eduDetails" :edit-item="editItem" />
      <!-- 拒绝归还 -->
      <el-dialog title="拒绝归还" :visible.sync="returnVisible" width="500px">
        <el-form :model="returnForm">
          <el-form-item label="拒绝原因" label-width="120px">
            <el-input v-model="returnForm.checkRefuseReason" autocomplete="off" placeholder="请输入拒绝原因" type="text"
              maxlength="50" show-word-limit></el-input>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button @click="closeReturn">取 消</el-button>
          <el-button type="primary" @click="confirmReturnVisible">确 定</el-button>
        </div>
      </el-dialog>
      <el-dialog width="500px" title="提示" :visible.sync="orderDialogVisible" :close-on-click-modal="false">
        <el-form :model="form" :rules="rules" ref="ruleFormOrder" label-width="100px">
          <el-form-item label="">
            <p>首次查看大数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?</p>
          </el-form-item>
          <el-form-item label="请选择分类" prop="goods_type">
            <el-select v-model="form.goodsType" placeholder="全部" @change="handleChange" clearable>
              <el-option v-for="item in goodsType" :key="item.value" :label="item.label" :value="item.value"></el-option>
            </el-select>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="orderDialogVisible = false">取 消</el-button>
          <el-button size="small" type="primary" @click="handleSubmit">确 定</el-button>
        </div>
      </el-dialog>
      <el-dialog width="520px" title="提示" :visible.sync="eduDialogVisible">
        <el-form ref="eduForm" :model="eduForm" :rules="rules" label-width="100px">
          <el-form-item label="证书编号" prop="certificateNo">
            <el-tooltip class="item" effect="dark" :content="content" placement="bottom">
              <el-input v-model="eduForm.certificateNo" placeholder="请输入证书编号" type="text" show-word-limit clearable />
            </el-tooltip>
          </el-form-item>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <el-button size="small" @click="closeReturnEdu">取 消</el-button>
          <el-button size="small" type="primary" @click="handleSubmitEdu">确 定</el-button>
        </div>
      </el-dialog>
    </div>

  </div>
</template>
  
<script>
import globalData from "../../utils/global";
import customPage from "@/components/customPage";
import myDatePicker from "@/components/myDatePicker"
import {
  orderList,
  getOrderStatus,
  orderListExport,
  orderFinish,
  orderReturnAgree,
  orderReturnRefuse,
  orderComfirmReturn,
  orderReturnFinish,
  orderClose,
  orderRisk,
  getBooleaRiskNum,
  orderRefuse,
  createCreditCompany,
  orderDetail, handleOrder,setNextOrder,setOrderEdit
} from "@/api/order"
import { rejectRefund, orderCheckPass, returnOrder } from '../../api/orderRefund'
import checkLease from './dialogs/checklease';
import setAddress from '../order/dialogs/setAddress';
import setDevice from './dialogs/setDevice';
import setRemark from './dialogs/setRemark';
import checkRemark from './dialogs/checkRemark';
import checkFlow from './dialogs/checkFlow';
import delivery from './dialogs/delivery';
import receipt from './dialogs/receipt';
import authInfo from './dialogs/authInfo';
import checkBill from './dialogs/checkBill';
import checkLogistics from './dialogs/checkLogistics';
import editOrder from './dialogs/editOrder';
import selectRisk from './dialogs/selectRisk';
import insurance from './dialogs/Insurance';
import paramDialog from './dialogs/paramDialog';
import selectCredit from "./dialogs/selectCredit"
import radar from "./dialogs/radar"
import eduDetails from './dialogs/eduDetails'
import billAbDialog from './dialogs/billAbDialog'
import newSelectRisk from './dialogs/newSelectRisk'
export default {
  components: { paramDialog, insurance, myDatePicker, customPage, checkLease, setAddress, setDevice, setRemark, checkRemark, checkFlow, delivery, receipt, authInfo, checkBill, checkLogistics, editOrder, selectRisk, selectCredit, radar, eduDetails, billAbDialog, newSelectRisk },
  data() {
    return {
      searchForm: {
        orderNo: '',
        goodsName: '',
        receivingName: '',
        receivingMobile: '',
        riskName: '',
        riskMobile: '',
        orderStatus: '',
        orderCreateTime: ''
      },
      searchId:{
        orderId:''
      },
      form: {
        goodsType: "",
      },
      goodsType: [
        {
          label: '其他',
          value: 0
        },
        {
          label: '游戏电玩',
          value: 1
        },
        {
          label: '娱乐影音',
          value: 2
        },
        {
          label: '电脑平板',
          value: 3
        },
        {
          label: '手机优选',
          value: 4
        }
      ],
      statusList: globalData.orderStatus,
      total: 0,
      tableData: [],
      showFace: false,
      showFront: false,
      showBack: false,
      // activeName: 'all',
      selectedId: '',
      editItem: {},
      selectList: [],
      returnVisible: false,
      refuseId: '',
      returnForm: {
        checkRefuseReason: ''
      },
      InsuranceList: [
        {
          member_id: 1653450768,
          mechanism: '广州皓海同舟信息技术有限公司'
        }
      ],
      dialogVisible: false,
      orderDialogVisible: false,
      dialogType: 1,
      responseInfo: {},
      requestInfo: {},
      dataItem: {}, // 查看大数据
      eduDialogVisible: false,
      eduForm: {
        order_id: '',
        certificateNo: ''
      },
      eduId: '',
      content: '如果没有输入证书编号，则只能查询简要信息如：(姓名、证件号码、学历层次)',
      newOrderId: '',
      titleDialog:'',
      remarkList:[]
    }
  },
  mounted() {
    this.form.goodsType = this.goodsType[4].label
    this.typeId = this.goodsType[4].value
    if (this.$route.params.orderId) {
      this.searchForm.orderNo = this.$route.params.orderId
    }
    this.getSelect()
    this.getList()
  },
  methods: {
        // 上公证信息
        notarization(id){
      this.$confirm(
        '是否给该用户上协议公证',
        {
          confirmButtonText: '确定',
          cancelButtonText: '取消'
        }
      )
        .then(() => {
          setOrderLease({orderId:id}).then(res=>{
            this.$message({
            message: '申请成功',
            type: 'success'
          }) 
          this.getList()
          })
        })
        .catch(() => { })
    },
    setIsSuccess(setIsSuccess) {
      this.isSuccess = setIsSuccess
    },
    openTip(item) {
      this.$confirm('是否确认蚁盾风控?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          orderRisk({ orderId: item.id }).then((res) => { })
          this.getList()
        })
        .catch(() => { })
    },
    handleRefundOrder(tradeNo) {
      this.$router.push({ name: 'refundList', params: { tradeNo } })
    },
    // 查看合同
    checkPact(url) {
      window.open(url)
    },
		    //查看征信
    selectCredit(item) {
			getFirstCreditNewData({ orderId: item.id }).then(res => {

			})
			setTimeout(() => {
				this.$confirm('首次查看征信报告会使征信报告余量减1次，后续不扣余量并且可在"营销->征信报告"内查看，是否确认查看征信报告？', '提示', {
					confirmButtonText: '确定',
					cancelButtonText: '取消'
				}).then(() => {
					this.newOrderId = item.id
					// this.editItem = {
					//   orderId: item.id,
					//   cert_name: item.cert_name,
					//   cert_no: item.cert_no,
					//   mobile: item.mobile
					// }
					// this.$refs.selectCredit.dialogVisible = true
					this.$refs.newSelectRisk.dialogVisible = true
				}).catch(() => { })
        this.$router.go(0)
			}, 500);
    },
    // 蚂蚁风控
    antsDialog(item) {
      this.$confirm('是否确认查看蚂蚁风控?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.editItem = item
          this.$refs.eduDetails.dialogVisible = true
        })
        .catch(() => { })
    },
    // 签署担保合同
    createCreditCompany(id) {
      this.$confirm("订单上征信后无法取消，确定要上征信吗？", "确认上征信", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(() => {
          createCreditCompany(id).then((res) => {
            this.getList();
          });
        })
        .catch(() => { });
    },
    // 查看保单
    checkContract(pactUrl) {
      if (!pactUrl) {
        this.$message.warning('暂无保单');
      } else {
        window.open(this.$globalObj.imgBaseUrl + pactUrl)
      }
    },
    // 查看是否上保
    getParams(row) {
      this.dialogType = 2
      this.dialogVisible = true
      this.responseInfo = row ? row : {}
      this.requestInfo = {}
    },
    // 关闭查看上保
    closeDialog() {
      this.dialogVisible = false
    },
    // 订单完结
    finishOrder(id) {
      this.$confirm('交易完成后进行解约现有款项不退款，并解约代扣无法发起未代扣的期数！', '请确认是否交易完成？', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        orderFinish(id).then(res => {
          this.getList()
        });
      }).catch(() => { })
    },
    // 同意归还
    agreeReturn(id) {
      this.$confirm('确定要同意归还吗？', '同意归还', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        orderReturnAgree(id).then(res => {
          this.getList()
        });
      }).catch(() => { })
    },
    // 拒绝归还
    refuseReturn(id) {
      this.refuseId = id
      this.returnVisible = true
    },
    // 订单关闭
    closeOrder(id) {
      this.$confirm('确定要关闭订单吗？', '关闭', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        orderClose(id).then(res => {
          this.getList()
        });
      }).catch(() => { })
    },
    // 审核拒绝
    refuseOrder2(id) {
      this.$confirm('确定要拒绝订单吗？', '拒绝', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          orderRefuse(id).then((res) => {
            this.getList()
          })
        })
        .catch(() => { })
    },
    // 查看学历
    educationDialog(item) {
      this.$confirm('是否确认查看蚂蚁风控?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.editItem = item
          this.$refs.eduDetails.dialogVisible = true
        })
        .catch(() => { })
    },
    closeReturnEdu() {
      this.eduDialogVisible = false
      this.eduForm.certificateNo = ''
    },
    handleSubmitEdu() {
      this.$refs['eduForm'].validate((valid) => {
        console.log(this.eduForm);
        if (valid) {
          this.eduId = this.eduForm.certificateNo
          this.eduDialogVisible = false
          this.$refs.eduDetails.dialogVisible = true
          this.eduForm = {}
          // this.getList()
        } else {
          this.$message({
            message: '请选择类型',
            type: 'error'
          })
          return false
        }
      })
    },
    closeReturn() {
      this.returnVisible = false
      this.returnForm.checkRefuseReason = ''
    },
    confirmReturnVisible() {
      if (!this.returnForm.checkRefuseReason) {
        this.$message.warning('拒绝原因不能为空')
        return false
      }
      orderReturnRefuse({
        orderId: this.refuseId,
        checkRefuseReason: this.returnForm.checkRefuseReason
      }).then((res) => {
        this.getList()
        this.closeReturn()
      }).catch(() => { })
    },
    // 确认归还
    confirmReturn(id) {
      this.$confirm('确定要归还吗？', '确认归还', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      }).then(() => {
        orderComfirmReturn(id).then(res => {
          this.getList()
        })
      }).catch(() => { })
    },
    // 归还完成
    // finishReturn(id){
    //   orderReturnFinish(id).then(res => {
    //     this.getList();
    //   });
    // },
    // 查看物流
    checkLogistics(item) {
      this.editItem = item
      this.$refs.checkLogistics.dialogVisible = true
    },
    // 查看已付账单详情
    checkPaidBill(id, paid_rent) {
      if (this.$hasMethod('#checkBill') && paid_rent > 0) {
        this.selectedId = id
        this.$refs.checkBill.dialogVisible = true
      }
    },
    // 查看认证资料
    checkAuthInfo(item) {
      this.editItem = {
        face_photo: item.face_photo,
        idcard_back: item.idcard_back,
        idcard_front: item.idcard_front
      }
      this.$refs.authInfo.dialogVisible = true
    },
    // 确认收货
    confirmReceipt(id) {
      this.selectedId = id
      this.$refs.receipt.dialogVisible = true
    },
    // 订单发货
    openDelivery(id) {
      this.selectedId = id
      this.$refs.delivery.dialogVisible = true
    },
    // 购买保险
    buyInsurance(id) {
      this.tableData.forEach(item => {
        if (item.id === id) {
          this.InsuranceList.push({
            mechanism: item.mechanism,
            member_id: item.member_id
          })
        }
      })
      this.InsuranceList = this.InsuranceList.filter((element, index, self) => {
        return self.findIndex(x => x.member_id === element.member_id) === index
      })
      this.selectedId = id
      this.$refs.insurance.dialogVisible = true
    },
    // 拒绝订单
    refuseorder(id) {
      this.$confirm('请确认是否拒绝该订单?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          rejectRefund({
            order_id: id
          })
            .then((res) => {
              // console.log(res);
              this.getList()
            })
            .catch(() => { })
        })
        .catch(() => { })
    },
    // 审核通过
    checkPass(id,sell_id) {
      if(sell_id==1649320702){
        this.$confirm('是否确定转回内部平台?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          setOrderEdit(id)
            .then((res) => {
              this.getList()
            })
            .catch(() => { })
        })
        .catch(() => { })
      }else{
        this.$confirm('需要上征信的订单必须要在审核通过前执行上征信操作完成，请确认是否审核通过该订单?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          orderCheckPass({
            orderId: id
          })
            .then((res) => {
              // console.log(res);
              this.getList()
            })
            .catch(() => { })
        })
        .catch(() => { })
      }
    },
    // 转回平台
    returnOrder(id) {
      this.$confirm('是否拒绝该订单并转回平台?', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          returnOrder({
            orderId: id
          })
            .then((res) => {
              // console.log(res);
              this.getList()
            })
            .catch(() => { })
        })
        .catch(() => { })
    },
    // 查看流水记录
    viewFlow(trade_no) {
      this.selectedId = trade_no
      this.$refs.checkFlow.dialogVisible = true
    },
    // 查看客服备注
    viewRemark(id) {
      this.selectedId = id
      this.$refs.checkRemark.dialogVisible = true
    },
    // 添加客服备注
    addRemark(id,type) {
      if(type==1){
        this.titleDialog="风控建议"
      }else{
        this.titleDialog="客服备注"
      }
      this.selectedId = id
      this.$refs.setRemark.dialogVisible = true
    },
    // 更改设备编号
    editDevice(item) {
      this.editItem = {
        orderId: item.id,
        deviceNumber: item.device_number ? item.device_number.split(',') : [],
        amount: item.amount
      }
      this.$refs.setDevice.dialogVisible = true
    },
    // 修改地址
    editAddress(item) {
      console.log(111);
      this.editItem = {
        orderId: item.id,
        realname: item.realname,
        mobile: item.address_mobile,
        address: item.address,
        prov: item.prov,
        city: item.city,
        area: item.area,
        province: [item.prov, item.city, item.area]
      }
      console.log(this.editItem);
      this.$refs.setAddress.dialogVisible = true
    },
    // 查看租期
    viewLease(id) {
      this.selectedId = id
      this.$refs.checkLease.dialogVisible = true
    },
    // 编辑订单
    editorder(item, num) {
      // 1 租赁方式  2 每期租金 3 买断金 4 更改押金
      this.editItem = {
        orderId: item.id,
        pact_type: item.pact_type_number,
        month_total: item.month_total,
        setmeal_price: item.setmeal_price,
        rent: '',
        activity_id: item.activity_id > 0 ? 1 : 2,
        setmeal_foregift_apply: item.setmeal_foregift_apply ? item.setmeal_foregift_apply : 0,
        setmeal_foregift: item.setmeal_foregift,
        num: num
      }
      this.$refs.editOrder.dialogVisible = true
    },
    handleOrderData(item) {
      this.dataItem = item
      this.orderDialogVisible = true
      this.getList();
    },
    handleOrder(id) {
      this.$confirm('确定稍后处理?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          handleOrder({
            orderId: id
          }).then(res => {
            this.$message({
              message: "操作成功！",
              type: "success"
            })
            this.getList()
          })
        })
        .catch(() => { })
    },
    // 查看雷达风控数据
    radarDialog(item) {
      console.log(item);
      this.$confirm('首次查看雷达大数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.editItem = {
            orderId: item.id,
            cert_name: item.authentic.cert_name,
            cert_no: item.authentic.cert_no,
            mobile: item.mobile
          }
          console.log(this.editItem);
          this.$refs.radarDialog.dialogVisible = true
          // this.getList()
          this.respCode()
        })
        .catch(() => { })
    },
    respCode(data) {
      console.log(data);
      if (data.length == 0) {
        this.$message({
          message: "该用户没有雷达风控数据风险",
          type: "error"
        })
      }
    },
    // 查看钞能力风控数据
    billAbDialog(item) {
      console.log(item);
      this.$confirm('首次查看钞能力风控数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消'
      })
        .then(() => {
          this.editItem = {
            orderId: item.id,
            cert_name: item.cert_name,
            cert_no: item.cert_no,
            mobile: item.mobile
          }
          console.log(this.editItem);
          this.$refs.billAbDialog.dialogVisible = true
          // this.getList()
          // this.respCode()
        })
        .catch(() => { })
    },
    handleSubmit() {
      this.$refs['ruleFormOrder'].validate((valid) => {
        if (valid) {
          getBooleaRiskNum(this.dataItem.id).then((res) => {
            if (res.data !== 1) {
              this.editItem = {
                orderId: this.dataItem.id,
                cert_name: this.dataItem.authentic.cert_name,
                cert_no: this.dataItem.authentic.cert_no,
                mobile: this.dataItem.mobile,
                rent_total: this.dataItem.rent_total,
                month_total: this.dataItem.month_total,
                website_price: this.dataItem.website_price,
                new_grade: this.dataItem.new_grade,
                goods_type: this.typeId
              }
              this.orderDialogVisible = false
              this.$refs.selectRisk.dialogVisible = true
            }
          })
        } else {
          this.$message({
            message: "请选择类型",
            type: "error"
          })
          return false
        }
      })
    },
    //查看风控大数据
    // selectRisk(item) {
    //   this.$confirm('首次查看大数据会使风控余量减1次，后续不扣余量并且可在"营销->布尔数据"内查看，是否确认查看大数据?', '提示', {
    //     confirmButtonText: '确定',
    //     cancelButtonText: '取消'
    //   })
    //     .then(() => {
    //       // 查询布尔数据余量
    //       getBooleaRiskNum(item.id).then((res) => {
    //         if (res.data !== 1) {
    //           this.editItem = {
    //             orderId: item.id,
    //             cert_name: item.cert_name,
    //             cert_no: item.cert_no,
    //             mobile: item.mobile,

    //           }

    //           this.$refs.selectRisk.dialogVisible = true
    //         }
    //       })
    //       this.getList()
    //     })
    //     .catch(() => { })
    // },
    getOrderStatusType(status) {
      const obj = this.statusList.find(item => item.id === status)
      return obj ? obj.type : 'warning'
    },
    getOrderStatusName(status) {
      const obj = this.statusList.find(item => item.id === status)
      return obj ? obj.name : ''
    },
    // 获取数据
    getList(flag) {
      // flag为true, 则不刷新表格
      // const { page, pageSize } = this.$refs.customPage
      this.remarkList=[]
      if (!flag) {
        console.log(1);
        this.tableData = []
      }
      orderDetail({

      }).then(res => {
        this.tableData = res
        this.tableData.orderRemark.find(item=>{
          if(item.type==9){
            this.remarkList.push(item)
          }
        })
      })
    },
    // 查询
    search() {
      const pickerVal = this.$refs.myDatePicker.getVal()
      if (pickerVal !== 'error') {
        this.searchForm.orderCreateTime = pickerVal
        this.$refs.customPage.page = 1
        this.getList()
      }
    },
    // 重置
    reset() {
      if (this.$refs.myDatePicker) {
        this.$refs.myDatePicker.reset()
      }
      this.searchForm = {
        orderNo: '',
        goodsName: '',
        receivingName: '',
        receivingMobile: '',
        riskName: '',
        riskMobile: '',
        orderStatus: '',
        orderCreateTime: ''
      }
      this.getList()
    },
    // 导出
    exportFile() {
      const pickerVal = this.$refs.myDatePicker.getVal()
      if (pickerVal !== 'error') {
        this.searchForm.orderCreateTime = pickerVal
        orderListExport({
          ...this.searchForm,
          orderStatusGroup: this.activeName
        })
      }
    },
    handleClick(tab) {
      this.activeName = tab.name
      this.$refs.customPage.page = 1
      this.getList()
    },
    handleSet(){
      setNextOrder(this.searchId.orderId).then(res=>{
        this.$message({
          message: "设置成功",
          type: "success"
        })
      })
    },
    getSelect() {
      getOrderStatus().then(res => {
        const list = []
        for (const key in res) {
          list.push({
            id: key,
            name: res[key]
          })
        }
        this.selectList = list || []
      })
    }
  }
}
</script>
  
<style lang="scss" scoped>
.el-row {
  margin-bottom: 10px;
}

.bor_cls {
  border: 1px solid #DCDCDC;
  padding: 5px;
  border-radius: 3px 3px 3px 3px;
  font-size: 14px;
}

.container {
  background-color: #EEEEEE;
}

.goods_cls div {
  margin-bottom: 20px;
}

.item {
  margin-left: 10px;
}

.border_cls {
  padding: 20px;
  margin-bottom: 20px;
  background: #FFFFFF;
  box-shadow: 0px 0px 4px 0px rgba(0, 0, 0, 0.06);
  border-radius: 4px 4px 4px 4px;
}

.font_cls {
  font-size: 16px;
  font-family: Microsoft YaHei-Bold, Microsoft YaHei;
  font-weight: bold;
  color: #E43C3A;
}

.btn_cls {
  position: relative;
  bottom: -200px;

  .el-button {
    margin-bottom: 20px;
  }
}

.common_form_search {
  padding: 15px 30px 0;
}

.child_page {
  padding-bottom: 15px;
  padding-left: 30px;
  padding-right: 30px;

  p,
  div {
    box-sizing: border-box;
  }
}

.list_wrap {
  position: relative;
}

.list_header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  min-height: 50px;
  z-index: 2;
  background: #f5f5f5;
  border: 1px solid #e6e6e6;

  p {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
  }

  p:not(:first-child) {
    border-left: 1px solid #e6e6e6;
  }
}

.list_item {
  display: block;
  border: 1px solid #e6e6e6;
  margin-top: 10px;
}

.item_row {
  border-top: 1px solid #e6e6e6;

  &>div {
    padding: 10px;
    color: #666666;

    &:not(:first-child) {
      border-left: 1px solid #e6e6e6;
    }
  }
}

.detail,
.btns {
  padding: 10px;
}

.every {
  border-bottom: 1px solid #f5f5f5;
  margin-top: -60px;
  padding-bottom: 0;
}

.every .el-tag {
  width: 74px;
  text-align: center;
  font-size: 14px;
}

.btns {

  // border-left: 1px solid #e6e6e6;
  .el-button+.el-button {
    margin-left: 10px;
  }
}

.border-btn {
  width: 150px;
  height: 30px;
  margin-bottom: 10px;
  padding-top: 0;
  padding-bottom: 0;
  background: #ffffff;
  border: 1px solid $mainBlue;
  border-radius: 3px;
  color: $mainBlue;
  font-size: 12px;
}

.sign_icons img {
  // width: 21px;
  height: 23px;
  margin-right: 2px;
}

.item_header {
  padding: 5px 10px;
  background-color: #f5f5f5;

  &>div p {
    color: #666666;
    font-size: 12px;
    padding-left: 20px;
  }
}

.title {
  font-size: 16px;
  line-height: 23px;
  padding-bottom: 15px;
}

.meal,
.device {
  font-size: 12px;
  color: #999999;
  line-height: 23px;
}

.item_row p {
  line-height: 23px;
}

.item_row div {
  line-height: 20px;
}

.btns {
  padding-left: 0;
}

.btns .el-button {
  margin-left: 10px;
  margin-bottom: 10px;
}

.text-ellipsis span {
  color: purple;
}

.el-image-viewer__wrapper {
  z-index: 2090 !important;
}</style>